<?php 
//$post_term = wp_get_post_terms( $post->ID, 'category' );
//$category_slug = $post_term[0]->slug;
$cat_id = get_query_var('category_name');

query_posts(array('post_type' => 'cat_head', 'category_name' => $cat_id, 'posts_per_page' => 1 ));  

if ( ! have_posts() ) {
	if (get_option_tree('select_blog_header', '')) {
	$blog_header_element = get_option_tree('select_blog_header', '');
	if ($blog_header_element == 'Post Slider'){
	get_header('post-slider'); }
	if ($blog_header_element == 'Orbit slider'){
	get_header('orbit-slider'); }
	if ($blog_header_element == 'Custom Header'){
	get_header('custom-element'); }
	if ($blog_header_element == 'Custom Header w/ background'){
	get_header('custom-element-bg'); }
	if ($blog_header_element == 'None'){
	get_header(); } 
	} else {
	get_header();} 
	
	if (get_option_tree('diable_cat_title', '')) {} else { echo '<h1 class="category-title">', single_cat_title() .'</h1>' ;}
} else {
while ( have_posts() ) : the_post(); 
if (get_post_meta($post->ID, 'header_choice_select', true));{ get_header(get_post_meta($post->ID, 'header_choice_select', true)); } 
endwhile; 
if (get_option_tree('diable_cat_title', '') || get_post_meta($post->ID, 'cat_title_check', true) != 'off') {} else { echo '<h1 class="category-title">', single_cat_title() .'</h1>' ;}
} 
wp_reset_query(); ?>

	 
<?php if (get_option_tree('blog_layout_sidebar', '')) { echo '<div id="content_full" >'; } else {echo '<div id="content" class="left">';} ?> 

<?php get_template_part( 'loop', 'index' ); ?>

</div><!-- #content -->
<?php if (get_option_tree('blog_layout_sidebar', '')) {} else {echo '<div id="sidebar_right">', get_sidebar() . '</div>';}?>
<div class="clear"></div>
<?php get_footer(); ?>